package org.redr.widgetGUI.core;

import org.redr.widgetGUI.settings.WidgetSettings;
import org.redr.widgetGUI.settings.WidgetState;

import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLayout;

public class StatusLabel extends WidgetState{
	
	public static int	DATAPROCESSINGCOMPLETE	=	5;
	public static int	DATAPROCESSING	=	4;
	public static int	NEWDATA	=	3;
	public static int 	WARNING	=	2;
	public static int	ERROR	=	1;
	public static int	OK	=	0;
	private QLabel	label;
	
	public QLabel widget(){
		return label;
	}
	public StatusLabel(LayoutState p, WidgetSettings ws){
		super(p, ws);
		label	=	new QLabel();
		p.addWidget(label);
		setStatus(Integer.valueOf(_getSetting("status", "0")));
	}
	
	public StatusLabel(QLayout p, WidgetSettings ws){
		super(p, ws);
		label	=	new QLabel();
		p.addWidget(label);
	}
	
	public void setText(String s){
		label.setText(s);
	}
	
	public void setText(String s, String c){
		label.setText(s);
		label.setStyleSheet("QLabel { background-color: " + c + "}");
		
	}
	
	public void setStatus(int s){
		settings.setSetting("status", String.valueOf(s));
		if(s == WARNING){
			setText("No Data To Process");
		} else if (s == ERROR){
			setText("Error", "#ff0000");
		} else if (s == OK){
			setText("Data Processed and Sent", "#00ff00");
		} else if (s == NEWDATA){
			setText("New Data Recieved", "#ffff00");
		} else if (s == DATAPROCESSING){
			setText("Data Processing", "#ffff00");
		} else if (s == DATAPROCESSINGCOMPLETE){
			setText("Data Processing Complete", "#00ff00");
		} else {
			setText("UNKNOWN STATUS SET", "#ff0000");
		}
	}

}
